<?php 
$count = $this->count;
$int = 0;
$data = array();
//Percentage of each
foreach ($this->pos as $val){
	
	$value = ($val/$count) * 100;
	//echo "Level $int Difficulty :". ($val/$count) * 100;
	array_push($data, round($value, 2));
	//echo"<br>";
	$int++;
}
//print_r($this->pos);
//echo "Printing..." .$this->pos[2];

?>

<?php if ($this->num == 0){
$url = $this->url(array("module"=>"community", "controller"=>"ratecourse", "action"=>"rate", "course"=>$this->course, "semester"=>$this->sem, "year"=>$this->year, "course_no"=>$this->courseNo));
$msg = "No data exists for this course yet<br><a href =$url>Be the first to rate this class!</a>";
}else{
$msg="Total Number of Respondents: $count" ;
}?>
<div id="instrdistro">Instructor Rating Distribution for <?php echo $this->data; ?></div><br></br>
<h4> <?php echo $msg;?></h4>
<?php $this->dojo()->enable();?>

<script type="text/javascript">
    dojo.require("dojox.charting.Chart2D");
    dojo.require("dojox.charting.plot2d.Pie");
    dojo.require("dojox.charting.action2d.Highlight");
    dojo.require("dojox.charting.action2d.MoveSlice");
    dojo.require("dojox.charting.action2d.Tooltip");
    dojo.require("dojox.charting.themes.MiamiNice");
    dojo.require("dojox.charting.widget.Legend");

    dojo.addOnLoad(function() {
        var dc = dojox.charting;
        var chartTwo = new dc.Chart2D("chartTwo");
        chartTwo.setTheme(dc.themes.MiamiNice).addPlot("default", {
            type: "Pie",
            font: "normal normal 11pt Tahoma",
            fontColor: "black",
            labelOffset: -30,
            radius: 80
        }).addSeries("Series A", [{
            y: <?php  echo $data[0];?>,
            text: "Very poor",
            stroke: "black",
            tooltip: "<?php echo $data[0];?>% of respondents thought the instructor of this class was very poor!"
        },
        {
            y: <?php echo $data[1];?>,
            text: "poor",
            stroke: "green",
            tooltip: "<?php echo $data[1];?>% of respondens thought the instructor of this class was poor!"
        },
        {
            y: <?php  echo $data[2];?>,
            text: "Average",
            stroke: "black",
            tooltip: "<?php echo $data[2];?>% of respondents thought the instructor of the instructor was average!"
        },
        {
            y: <?php  echo $data[3];?>,
            text: "Good",
            stroke: "black",
            tooltip: "<?php echo $data[3];?>% of respondents thought the instructor was good!"
        },
        {
            y: <?php  echo $data[4];?>,
            text: "Excellent",
            stroke: "black",
            tooltip: "<?php echo $data[4];?>% of respondents thought the instructor was excellent!"
        }
        ]);
        var anim_a = new dc.action2d.MoveSlice(chartTwo, "default");
        var anim_b = new dc.action2d.Highlight(chartTwo, "default");
        var anim_c = new dc.action2d.Tooltip(chartTwo, "default");
        chartTwo.render();
    });
</script>
<div id="chartTwo" style="width: 300px; height: 300px;">
</div>
<div id="legendTwo">
</div>